package com.edu.bean;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.NumberFormat;

import javax.validation.constraints.*;
import java.util.Date;

public class User {
    private int userId;

    @NotNull(message = "账户不能为空")
    @Pattern(regexp = "^(?=.*[a-zA-Z])(?=.*\\d)[a-zA-Z\\d]{6,10}$",message = "账号长度在6-10位之间，并且包含数字字母组合")
    private String userName;

    @NotNull(message = "密码不能为空")
    @Pattern(regexp = "^(?=.*[a-zA-Z])(?=.*\\d)[a-zA-Z\\d]{6,10}$",message = "密码长度在6-10位之间，并且包含数字字母组合")
    private String userPass;

    @Range(min = 1,max = 150,message = "最小1岁最大150岁")
    private int userAge;

    @NotNull(message = "性别不能为空")
    @Pattern(regexp = "^[男女]$",message = "不能是除了男女以外的性别")
    private String userSex;

    @NotNull(message = "生日不能为空")
    @Past(message = "请输入一个过去的时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd",fallbackPatterns = {"yyyy/MM/dd","yyyy年MM月dd日"})
    private Date birthDay;

    @DecimalMin(value = "1800",message = "最低工资应当是1800+")
    @NumberFormat(style = NumberFormat.Style.CURRENCY,pattern = "￥#,###.##")
    private double salary;

    @NumberFormat(style = NumberFormat.Style.PERCENT)
    private double winRate;

    @NotEmpty(message = "邮箱不能为空")
    @Email(message = "不是一个合格的Email格式")
    private String email;

    private String headImg;

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPass() {
        return userPass;
    }

    public void setUserPass(String userPass) {
        this.userPass = userPass;
    }

    public int getUserAge() {
        return userAge;
    }

    public void setUserAge(int userAge) {
        this.userAge = userAge;
    }

    public String getUserSex() {
        return userSex;
    }

    public void setUserSex(String userSex) {
        this.userSex = userSex;
    }

    public Date getBirthDay() {
        return birthDay;
    }

    public void setBirthDay(Date birthDay) {
        this.birthDay = birthDay;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public double getWinRate() {
        return winRate;
    }

    public void setWinRate(double winRate) {
        this.winRate = winRate;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getHeadImg() {
        return headImg;
    }

    public void setHeadImg(String headImg) {
        this.headImg = headImg;
    }

    public User() {
    }

    public User(String userName, String userPass, int userAge, String userSex, Date birthDay, double salary, double winRate, String email, String headImg) {
        this.userName = userName;
        this.userPass = userPass;
        this.userAge = userAge;
        this.userSex = userSex;
        this.birthDay = birthDay;
        this.salary = salary;
        this.winRate = winRate;
        this.email = email;
        this.headImg = headImg;
    }

    public User(int userId, String userName, String userPass, int userAge, String userSex, Date birthDay, double salary, double winRate, String email, String headImg) {
        this.userId = userId;
        this.userName = userName;
        this.userPass = userPass;
        this.userAge = userAge;
        this.userSex = userSex;
        this.birthDay = birthDay;
        this.salary = salary;
        this.winRate = winRate;
        this.email = email;
        this.headImg = headImg;
    }

    @Override
    public String toString() {
        return "User{" +
                "userId=" + userId +
                ", userName='" + userName + '\'' +
                ", userPass='" + userPass + '\'' +
                ", userAge=" + userAge +
                ", userSex='" + userSex + '\'' +
                ", birthDay=" + birthDay +
                ", salary=" + salary +
                ", winRate=" + winRate +
                ", email='" + email + '\'' +
                ", headImg='" + headImg + '\'' +
                '}';
    }
}
